import api from '@/utlis/api.js';

//查询字典数据
export const dict = (dictType, value) => {
	return new Promise((resolve, reject) => {
		api("app/dict/data/type/" + dictType, "GET").then(res => {
			const dictOption = [];
			for (var i = 0; i < res.data.length; i++) {
				dictOption.push({
					"dictCode": res.data[i].dictCode,
					"dictType": res.data[i].dictType,
					"dictLabel": res.data[i].dictLabel,
					"dictValue": res.data[i].dictValue,
					"remark": res.data[i].remark,
				});
			}
			resolve(dictOption);
		}).catch(err => {
			reject(err);
		});
	});
}


//根据数据编号查询数据详情
export const dictData = (dictCode) => {
	return new Promise((resolve, reject) => {
		api("app/dict/data/" + dictCode, "GET").then(res => {
			resolve({
				"dictCode": res.data.dictCode,
				"dictType": res.data.dictType,
				"dictLabel": res.data.dictLabel,
				"dictValue": res.data.dictValue,
				"remark": res.data.remark,
			});
		}).catch(err => {
			reject(err);
		});
	})
}

//查询字典列表
export const dictList = () => {
	return new Promise((resolve, reject) => {
		api("app/dict/type/list", "GET").then(res => {
			resolve(res);
		}).catch(err => {
			reject(err)
		});
	});
}
export const DICT_TYPE = Object.freeze({
	SYS_USER_SEX: "sys_user_sex",
	SYS_SHOW_HIDE: "sys_show_hide",
	SYS_NOTICE_DISABLE: "sys_normal_disable",
	SYS_YES_NO: "sys_yes_no",
	SYS_NOTICE_TYPE: "sys_notice_type",
	SYS_NOTICE_STATUS: "sys_notice_status",
	SYS_OPER_TYPE: "sys_oper_type",
	SYS_COMMON_STATUS: "sys_common_status",
	APPLICATION_YES_NO: "application_yes_no",
	EDUCATIONAL_TYPE: "educational_type",
	PROFESSIONAL_TYPE: "professional_type",
	QUESTION_STATUS: "question_status",
	SERVICE_TYPE: "service_type",
	RELATION_TYPE: "relation_type",
	ARTICLE_APP_QURRY_LIST: "article_app_query_list",
	MINE_APP_CONTENT_LIST: "mine_app_content_list",
	MINE_APP_FEATURE_LIST: "mine_app_feature_list",
	FORUM_PUBLISH_ADDRESS: "forum_publish_address",
	ORDER_NAVIGATION: "order_navigation",
	MAP_NAVIGATION_LISt:"map_navigation_list",
	MAP_SUBSECTION_LISt:"map_subsection_list",
});